package com.leyou.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.leyou.entity.SpuDetailEntity;
import com.leyou.service.SpuDetailService;

import com.leyou.api.R;



/**
 * 
 *
 * @author Daifeng
 * @email 2661184062@qq.com
 * @date 2020-12-25 16:44:46
 */
@RestController
@RequestMapping("/spudetail")
public class SpuDetailController {
    @Autowired
    private SpuDetailService spuDetailService;



    /**
     * 获取商品详细信息
     */
    @RequestMapping("/info/{spuId}")
    public R SpuDetailInfo(@PathVariable("spuId") Long spuId){
		SpuDetailEntity spuDetail = spuDetailService.getById(spuId);

        return R.ok().put("data", spuDetail);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
  //  @RequiresPermissions("leyou:spudetail:save")
    public R save(@RequestBody SpuDetailEntity spuDetail){
		spuDetailService.save(spuDetail);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
  //  @RequiresPermissions("leyou:spudetail:update")
    public R update(@RequestBody SpuDetailEntity spuDetail){
		spuDetailService.updateById(spuDetail);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
   // @RequiresPermissions("leyou:spudetail:delete")
    public R delete(@RequestBody Long[] spuIds){
		spuDetailService.removeByIds(Arrays.asList(spuIds));

        return R.ok();
    }

}
